package com.libing.service.impl;

import com.libing.base.BaseDao;
import com.libing.base.BaseService;
import com.libing.dao.InvoiceInformationDao;
import com.libing.entity.InvoiceInformation;
import com.libing.entity.User;
import com.libing.enums.StateEnum;
import com.libing.service.InvoiceInformationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 开票信息 Service
 * @Auther: LEE
 * @Date: Create in 2018/6/27 10:13
 */
@Service
public class InvoiceInformationServiceImpl extends BaseService<InvoiceInformation> implements InvoiceInformationService {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private InvoiceInformationDao invoiceInformationDao;

    @Override
    public StateEnum insert(InvoiceInformation invoiceInformation) {
        return getCUDStatus(getBaseDao().insert(invoiceInformation));
    }

    @Override
    public StateEnum update(InvoiceInformation invoiceInformation) {
        return getCUDStatus(getBaseDao().update(invoiceInformation));
    }

    @Override
    public StateEnum delete(Long id) {
        return getCUDStatus(getBaseDao().delete(id));
    }

    @Override
    public List<InvoiceInformation> selectAll() {
        return invoiceInformationDao.selectAll();
    }


    @Override
    public InvoiceInformation selectById(Long id) {
        try {
            return getBaseDao().selectById(id);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }

    @Override
    protected BaseDao<InvoiceInformation> getBaseDao() {
        return this.invoiceInformationDao;
    }

}
